﻿using System;
using System.Collections.Generic;
using System.Text;
using Lswweb.Domain;
using Lswweb.Model;

namespace Lswweb.Controls
{
    public class UserList : SkinnedGridView<UserInfo>
    {
        protected override IList<UserInfo> GridViewDataSourceHandler(int pageIndex, int pageSize, out int totalRecord)
        {
            return Users.GetUsers(SearchKey,RoleType,pageSize,pageIndex,out totalRecord);
        }

        private string searchKey = string.Empty;
        /// <summary>
        /// 默认值从Url中读取参数SearchKey
        /// </summary>
        public string SearchKey
        {
            get 
            {
                if (string.IsNullOrEmpty(searchKey))
                    return SiteContext.Current.SearchKey;
                else
                    return searchKey;
            }
            set 
            { 
                searchKey=value;
            }
        }

        private RoleType? roleType=null;
        public RoleType RoleType
        {
            get
            {
                if (this.roleType == null)
                    return (RoleType)SiteContext.Current.Type;

                return (RoleType)this.roleType;
            }
            set { this.roleType = value; }
        }

        protected override string DefaultSkinFilename
        {
            get { return "User/UserList.ascx"; }
        }
    }
}
